package com.nidu.demo.common.enums;

import cn.hutool.core.util.ArrayUtil;
import com.nidu.demo.common.validation.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum UserTypeEnum implements IntArrayValuable {
    MEMBER(1, "会员"),

    ADMIN(2, "管理员");

    private final Integer type;

    private final String name;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(UserTypeEnum::getType).toArray();

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static UserTypeEnum of(Integer value) {
        return ArrayUtil.firstMatch(o -> o.getType().equals(value), values());
    }
    
} 